package cn.hdu.liang.arrays;

import net.mindview.util.Generated;

import java.util.Arrays;
import java.util.Comparator;


class CompTypeComparator implements Comparator<CompType> {
    public int compare(CompType o1, CompType o2) {
        return (o1.j < o2.j ? -1 : (o1.j == o2.j ? 0 : 1));
    }
}

public class ComparatorTest {
    public static void main(String[] args) {
        CompType[] a = Generated.array(new CompType[12], CompType.generator());
        System.out.println("排序之前:");
        System.out.println(Arrays.toString(a));

        Arrays.sort(a, new CompTypeComparator());
        System.out.println("排序之后:");
        System.out.println(Arrays.toString(a));
    }
}